//
//  UIView+Image.m
//  ITC_iOS
//
//  Created by iBenz on 2018/9/17.
//  Copyright © 2018年 Benz.L. All rights reserved.
//

#import "UIView+Image.h"

@implementation UIView(Image)

- (UIImage *)image {
//    UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0f);
//    [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO]; // iOS7/7++
//    UIImage * snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
//    UIGraphicsEndImageContext();
//    return snapshotImage;
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [UIScreen mainScreen].scale);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

@end
